![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
io-ts-reporters
Advanced tools
Error reporters for io-ts.
Currently this package only includes one reporter. The output is an array of strings in the format of:
Expecting ${expectedType} at ${path} but instead got: ${actualValue}
And for union types:
Expecting one of:
${unionType1}
${unionType2}
${...}
${unionTypeN}
at ${path} but instead got: ${actualValue}
yarn add io-ts-reporters
import * as t from 'io-ts'
import reporter from 'io-ts-reporters'
const User = t.interface({name: t.string})
// When decoding fails, the errors are reported
reporter.report(User.decode({nam: 'Jane'}))
//=> ['Expecting string at name but instead got: undefined']
// Nothing gets reported on success
reporter.report(User.decode({name: 'Jane'}))
//=> []
To only format the validation errors in case the validation failed (ie.
mapLeft
) use formatValidationErrors
instead.
import * as t from 'io-ts'
import {formatValidationErrors} from 'io-ts-reporters'
import * as E from 'fp-ts/Either'
import {pipe} from 'fp-ts/pipeable'
const User = t.interface({name: t.string})
const result = User.decode({nam: 'Jane'}) // Either<t.Errors, User>
E.mapLeft(formatValidationErrors)(result) // Either<string[], User>
For more examples see the tests.
io-ts-reporters version | required typescript version |
---|---|
1.0.0 | 3.5+ |
<= 0.0.21 | 2.7+ |
yarn
yarn run test
This library was created by OliverJAsh.
FAQs
Formatting of io-ts validation errors
The npm package io-ts-reporters receives a total of 260,186 weekly downloads. As such, io-ts-reporters popularity was classified as popular.
We found that io-ts-reporters demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.